/*
  Copyright 2011 fullkawa

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package jp.fullkawa.xnovel.content;

import jp.fullkawa.xnovel.exception.RequireException;

/**
 * ルビが付いた"部分の"文章
 * @author fullkawa
 *
 */
public class SentenceWithRuby extends Sentence
{
	/**
	 * sentenceと対応する部分のルビ
	 */
	private String ruby;

	public SentenceWithRuby()
	{
		super();
		this.setBr(false);
	}

	public SentenceWithRuby(String sentence, String ruby)
	{
		this();
		this.setSentence(sentence);
		this.setBr(false);
		this.setRuby(ruby);
	}

	public String getRuby() {
		return ruby;
	}

	public void setRuby(String ruby) {
		this.ruby = ruby;
	}

	public String getTag()
	{
		if (this.getSentence() == null || this.getSentence().length() == 0)
		{
			throw new RequireException("文章が入力されていません。");
		}
		if (this.getRuby() == null || this.getRuby().length() == 0) {
			throw new RequireException("ルビが振られていません。");
		}

		String tag_br = "";
		if (this.isBr()) {
			Object[] o = null;
			tag_br = super.getTag("tag.sentence.br", o);
		}

		Object[] o = { this.getSentence(), this.getRuby() };
		return super.getTag("tag.ruby", o) + tag_br;
	}
}
